package com.ycg.biquge.common;

import com.ycg.biquge.pojo.User;
import org.springframework.stereotype.Component;

/**
 * @author YCG
 * @date 2024-05-02 20:29
 * @description 用户信息上下文
 */
public class UserContext {

    private static final ThreadLocal<User> threadLocal = new ThreadLocal<>();

    public static User getUser() {
        return threadLocal.get();
    }

    public static void setUser(User user) {
        threadLocal.set(user);
    }

    public static void clear() {
        threadLocal.remove();
    }
}
